$(function() {
	jQuery.validator.addMethod("isMoney", function(value, element) {   
		return this.optional(element) || /^(([0-9]\d*)(\.\d{1,5})?)$|(0\.0?([1-9]\d?))$/.test(value);   
	}, "请正确填写金额");
	
	$("#add_franchiser_form").validate({
		errorPlacement:function(error,element) {  
			element.parent().find(".verror").html(error);
		},
		rules:{
			"accountType":{
				required:true
			},
			"franchiserFund.accountNo":{
				required:true,
				remote: {
					url: base + "admin/franchiser/checkAccountNo.action", 
					type: "POST", 
					data: {"franchiserFund.id": ($("#franchiserFund_id").val()), "franchiserFund.accountNo": ($("#franchiserFund.accountNo").val())}
				}
			},
			"franchiserFund.owner": {
				required:true
			},
			"franchiserFund.accountBalance":{
				isMoney:true
			},
			"franchiserFund.accountStatus":{
				required:true
			}
		},
		messages:{
			"accountType": {
				required: "请选择或输入账户类型"
			},
			"franchiserFund.accountNo": {
				required: "请输入账户号码",
				remote: "该账号已存在"
			},
			"franchiserFund.owner":{
				required: "请输入账户所属者"
			},
			"franchiserFund.accountBalance": {
				isMoney: "金额格式不正确"
			},
			"franchiserFund.accountStatus": {
				required: "请选择账户使用状态"
			}
		}
	});
});